<?php
class vendor_draft_log {

	var $CI;
	var $operation_log;

	public function __construct() {
		$this->CI =& get_instance();
		$this->CI->load->library("sys/operation_log");
		$this->operation_log =$this->CI->operation_log;
	}

	public function  insert_log($vendor_draft_id,$action_type,$create_by,$create_time,$explanation,$org_draft='',$draft=''){
		$differents='';
		if ($org_draft!='') {
			$differents=$this->get_differents($org_draft, $draft);
		}
		$this->operation_log->insert_log($vendor_draft_id,$action_type,$create_by,$create_time,$explanation,$differents);
	}

	public function delete_log($vendor_draft_id){
		$this->operation_log->delete_log($vendor_draft_id);
	}
	public function get_logs($vendor_draft_id){
		return $this->operation_log->get_logs($vendor_draft_id);
	}
	public function get_differents($org_draft,$draft){
		$differents="";
		if ($org_draft['company_name']!=$draft['company_name']) {
			$differents.="修改了 公司名称<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['company_name']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['company_name']."</span><br />";
		}
		if ($org_draft['province']!=$draft['province']) {
			$differents.="修改了 省/直辖市<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['province']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['province']."</span><br />";
		}
		if ($org_draft['city']!=$draft['city']) {
			$differents.="修改了 市<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['city']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['city']."</span><br />";
		}
		if ($org_draft['region']!=$draft['region']) {
			$differents.="修改了 地区/县镇<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['region']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['region']."</span><br />";
		}
		if ($org_draft['registered_capital']!=$draft['registered_capital']) {
			$differents.="修改了 注册资本<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['registered_capital']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['registered_capital']."</span><br />";
		}
		if ($org_draft['registration_time']!=$draft['registration_time']) {
			$differents.="修改了 注册时间<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['registration_time']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['registration_time']."</span><br />";
		}
		if ($org_draft['corpscale']!=$draft['corpscale']) {
			$differents.="修改了 公司规模<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['corpscale']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['corpscale']."</span><br />";
		}
		if ($org_draft['employees']!=$draft['employees']) {
			$differents.="修改了 员工人数<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['employees']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['employees']."</span><br />";
		}
		if ($org_draft['license_address']!=$draft['license_address']) {
			$differents.="修改了 营业执照地址<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['license_address']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['license_address']."</span><br />";
		}
		if ($org_draft['address']!=$draft['address']) {
			$differents.="修改了 公司实际地址<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['address']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['address']."</span><br />";
		}
		if ($org_draft['legal_person']!=$draft['legal_person']) {
			$differents.="修改了 法人姓名<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['legal_person']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['legal_person']."</span><br />";
		}
		if ($org_draft['boss']!=$draft['boss']) {
			$differents.="修改了 实际老板<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['boss']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['boss']."</span><br />";
		}
		if ($org_draft['phone']!=$draft['phone']) {
			$differents.="修改了 公司座机<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['phone']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['phone']."</span><br />";
		}
		if ($org_draft['fax']!=$draft['fax']) {
			$differents.="修改了 传真<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['fax']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['fax']."</span><br />";
		}
		if (($org_draft['highway_media']!=$draft['highway_media'])) {
			$org_draft['highway_media'] =$org_draft['highway_media']=="0"?"否":"是";
			$draft['highway_media'] =$draft['highway_media']=="0"?"否":"是";
			$differents.="修改了 经营高速大牌媒体<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['highway_media']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['highway_media']."</span><br />";
		}
		if (($org_draft['airport_media']!=$draft['airport_media'])) {
			$org_draft['airport_media'] =$org_draft['airport_media']=="0"?"否":"是";
			$draft['airport_media'] =$draft['airport_media']=="0"?"否":"是";
			$differents.="修改了 经营机场媒体<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['airport_media']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['airport_media']."</span><br />";
		}
		if (($org_draft['led_media']!=$draft['led_media'])) {
			$org_draft['led_media'] =$org_draft['led_media']=="0"?"否":"是";
			$draft['led_media'] =$draft['led_media']=="0"?"否":"是";
			$differents.="修改了 经营市区led媒体<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['led_media']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['led_media']."</span><br />";
		}
		if (($org_draft['cityad_media']!=$draft['cityad_media'])) {
			$org_draft['cityad_media'] =$org_draft['cityad_media']=="0"?"否":"是";
			$draft['cityad_media'] =$draft['cityad_media']=="0"?"否":"是";
			$differents.="修改了 经营城市常规媒体<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['cityad_media']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['cityad_media']."</span><br />";
		}

		if ($org_draft['highway_count']!=$draft['highway_count']) {
			$differents.="修改了 高速媒体数量<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['highway_count']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['highway_count']."</span><br />";
		}
		if ($org_draft['airport_count']!=$draft['airport_count']) {
			$differents.="修改了 机场媒体数量<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['airport_count']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['airport_count']."</span><br />";
		}
		if ($org_draft['led_count']!=$draft['led_count']) {
			$differents.="修改了 市区led大牌媒体数量<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['led_count']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['led_count']."</span><br />";
		}
		if ($org_draft['cityad_count']!=$draft['cityad_count']) {
			$differents.="修改了 市区常规大牌数量<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['cityad_count']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['cityad_count']."</span><br />";
		}
		if ($org_draft['popularity']!=$draft['popularity']) {
			if ($org_draft['popularity']=="0") {
				$org_draft['popularity']="无";
			}elseif ($org_draft['popularity']=="1"){
				$org_draft['popularity']="高";
			}
			elseif ($org_draft['popularity']=="2"){
				$org_draft['popularity']="中";
			}
			elseif ($org_draft['popularity']=="3"){
				$org_draft['popularity']="低";
			}
			if ($draft['popularity']=="0") {
				$draft['popularity']="无";
			}elseif ($draft['popularity']=="1"){
				$draft['popularity']="高";
			}
			elseif ($draft['popularity']=="2"){
				$draft['popularity']="中";
			}
			elseif ($draft['popularity']=="3"){
				$draft['popularity']="低";
			}
			$differents.="修改了 公司知名度<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['popularity']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['popularity']."</span><br />";
		}
		if ($org_draft['credit']!=$draft['credit']) {
			if ($org_draft['credit']=="0") {
				$org_draft['credit']="无";
			}elseif ($org_draft['credit']=="1"){
				$org_draft['credit']="高";
			}
			elseif ($org_draft['credit']=="2"){
				$org_draft['credit']="中";
			}
			elseif ($org_draft['credit']=="3"){
				$org_draft['credit']="低";
			}
			if ($draft['credit']=="0") {
				$draft['credit']="无";
			}elseif ($draft['credit']=="1"){
				$draft['credit']="高";
			}
			elseif ($draft['credit']=="2"){
				$draft['credit']="中";
			}
			elseif ($draft['credit']=="3"){
				$draft['credit']="低";
			}
			$differents.="修改了 公司信誉情况<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['credit']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['credit']."</span><br />";
		}
		if ($org_draft['price_type']!=$draft['price_type']) {
			if ($org_draft['price_type']=="0") {
				$org_draft['price_type']="未定义";
			}elseif ($org_draft['price_type']=="1"){
				$org_draft['price_type']="公司统一报价";
			}
			elseif ($org_draft['price_type']=="2"){
				$org_draft['price_type']="户外负责人根据行情定价";
			}
			elseif ($org_draft['price_type']=="3"){
				$org_draft['price_type']="随意定价";
			}
			if ($draft['price_type']=="0") {
				$draft['price_type']="未定义";
			}elseif ($draft['price_type']=="1"){
				$draft['price_type']="公司统一报价";
			}
			elseif ($draft['price_type']=="2"){
				$draft['price_type']="户外负责人根据行情定价";
			}
			elseif ($draft['price_type']=="3"){
				$draft['price_type']="随意定价";
			}
			$differents.="修改了 定价机制<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['price_type']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['price_type']."</span><br />";
		}
		if ($org_draft['decision_type']!=$draft['decision_type']) {
			if ($org_draft['decision_type']=="0") {
				$org_draft['decision_type']="未定义";
			}elseif ($org_draft['decision_type']=="1"){
				$org_draft['decision_type']="公司高层集体决策";
			}
			elseif ($org_draft['decision_type']=="2"){
				$org_draft['decision_type']="老板直接决策";
			}
			elseif ($org_draft['decision_type']=="3"){
				$org_draft['decision_type']="户外负责人决策";
			}
			if ($draft['decision_type']=="0") {
				$draft['decision_type']="未定义";
			}elseif ($draft['decision_type']=="1"){
				$draft['decision_type']="公司高层集体决策";
			}
			elseif ($draft['decision_type']=="2"){
				$draft['decision_type']="老板直接决策";
			}
			elseif ($draft['decision_type']=="3"){
				$draft['decision_type']="户外负责人决策";
			}
			$differents.="修改了 决策机制<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['decision_type']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['decision_type']."</span><br />";
		}
		if ($org_draft['license_valid']!=$draft['license_valid']) {
			$org_draft['license_valid'] =$org_draft['license_valid']=="0"?"否":"是";
			$draft['license_valid'] =$draft['license_valid']=="0"?"否":"是";
			$differents.="修改了 营业执照合格情况<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['license_valid']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['license_valid']."</span><br />";
		}
		if ($org_draft['orgcode_valid']!=$draft['orgcode_valid']) {
			$org_draft['orgcode_valid'] =$org_draft['orgcode_valid']=="0"?"否":"是";
			$draft['orgcode_valid'] =$draft['orgcode_valid']=="0"?"否":"是";
			$differents.="修改了 组织机构代码合格情况<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['orgcode_valid']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['orgcode_valid']."</span><br />";
		}
		if ($org_draft['tax_valid']!=$draft['tax_valid']) {
			$org_draft['tax_valid'] =$org_draft['tax_valid']=="0"?"否":"是";
			$draft['tax_valid'] =$draft['tax_valid']=="0"?"否":"是";
			$differents.="修改了 税务登记证合格情况<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['tax_valid']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['tax_valid']."</span><br />";
		}
		if ($org_draft['background']!=$draft['background']) {
			$differents.="修改了 公司背景介绍<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['background']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['background']."</span><br />";
		}
		if ($org_draft['contactsname0']!=$draft['contactsname0']) {
			$differents.="修改了 联系人1 姓名<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['contactsname0']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['contactsname0']."</span><br />";
		}

		if ($org_draft['contactspost0']!=$draft['contactspost0']) {
			$differents.="修改了 联系人1 职务<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['contactspost0']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['contactspost0']."</span><br />";
		}
		if ($org_draft['contactsphone0']!=$draft['contactsphone0']) {
			$differents.="修改了 联系人1 电话<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['contactsphone0']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['contactsphone0']."</span><br />";
		}
		if ($org_draft['contactsname1']!=$draft['contactsname1']) {
			$differents.="修改了 联系人2 姓名<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['contactsname1']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['contactsname1']."</span><br />";
		}

		if ($org_draft['contactspost1']!=$draft['contactspost1']) {
			$differents.="修改了 联系人2 职务<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['contactspost1']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['contactspost1']."</span><br />";
		}
		if ($org_draft['contactsphone1']!=$draft['contactsphone1']) {
			$differents.="修改了 联系人2 电话<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['contactsphone1']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['contactsphone1']."</span><br />";
		}if ($org_draft['contactsname2']!=$draft['contactsname2']) {
			$differents.="修改了 联系人3 姓名<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['contactsname2']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['contactsname2']."</span><br />";
		}

		if ($org_draft['contactspost2']!=$draft['contactspost2']) {
			$differents.="修改了 联系人3 职务<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['contactspost2']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['contactspost2']."</span><br />";
		}
		if ($org_draft['contactsphone2']!=$draft['contactsphone2']) {
			$differents.="修改了 联系人3 电话<br/>";
			$differents.="旧值为:<span class='invalid_log'>".$org_draft['contactsphone2']."</span><br />";
			$differents.="新值为:<span class='success_log'>".$draft['contactsphone2']."</span><br />";
		}
		return $differents;
	}
}